// module.exports={
//     //mode用来指定构建模式（可选值有：development和production）
//     mode: "development"
// }


const path = require('path')
const HtmlPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

const htmlPlugin = new HtmlPlugin({
    template: './src/index.html', //指定源文件路径
    filename: './index.html', //指定生成文件路径
});

module.exports = {
    mode: 'development',
    devtool:'eval-source-map',
    //打包入口文件路径
    entry: path.join(__dirname, './src/index.js'),
    output: {
        //指定出处文件路径
        path: path.join(__dirname, './dist'),
        //指定输出文件名称
        filename: 'js/index.js'
    },
    plugins: [htmlPlugin,new CleanWebpackPlugin()],
    devServer: {
        port: 9000
    },
    module: {//所有第三方文件的匹配规则
        rules: [//文件后缀名的匹配规则
            {test: /.css$/, use: ['style-loader', 'css-loader']},
            {test: /.less$/, use: ['style-loader', 'css-loader', 'less-loader']},
            {test: /.jpg|png|gif$/, use: ['url-loader?limit=1&outputPath=images']},
            {test: /.js$/, use: 'babel-loader', exclude: /node_modules/}
        ]
    },
    resolve:{
        alias:{
            '@':path.join(__dirname,'./src/')
        }
    }
}


